package com.saret.translate.type;

import com.saret.utils.UtfFileHandle;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

/**
 * @author biniam.gebremichael
 * @since 11/25/11
 */
public class TextEntity {
    File file;
    List<String> lines;

    public TextEntity(File file) {
        this.file = file;
        lines = UtfFileHandle.readFileToListOfLines(file);
    }

    public List<String> filter(String regex) {
        List<String> filtered = new ArrayList<String>();
        for (String line : lines) {
            if (line.length() > 2 && line.matches(regex)) {
                filtered.add(line);
            }
        }
        return filtered;
    }

    public List<String> getLines() {
        return lines;
    }
}
